package com.askinhand.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.askinhand.bean.AudioQues;
import com.askinhand.bean.PictureQues;
import com.askinhand.dao.IAudioQuesDAO;
import com.askinhand.service.IAudioQuestionService;

public class AudioQuestionService implements IAudioQuestionService{

	public IAudioQuesDAO getAudioQuesDAO() {
		return audioQuesDAO;
	}

	public void setAudioQuesDAO(IAudioQuesDAO audioQuesDAO) {
		this.audioQuesDAO = audioQuesDAO;
	}

	IAudioQuesDAO audioQuesDAO;

	public ArrayList<AudioQues> findAudioQues() {
		// TODO Auto-generated method stub
		ArrayList<AudioQues> result = (ArrayList<AudioQues>)audioQuesDAO.findAll();
		return result;
	}

	public void save(AudioQues aq) {
		// TODO Auto-generated method stub
		audioQuesDAO.save(aq);
	}
	
	public ArrayList personalQuesReturn(String uid) {
		// TODO Auto-generated method stub
		ArrayList<AudioQues> pic=new ArrayList<AudioQues>();
		
		
		List li=audioQuesDAO.findByUid(Integer.parseInt(uid));
		Iterator it=li.iterator();
		while(it.hasNext()){
			AudioQues picques=(AudioQues)it.next();
			pic.add(picques);
			
		}

		
		return pic;
	}

	public ArrayList questionFind(String status, String type) {
		// TODO Auto-generated method stub
		ArrayList<AudioQues> result=new ArrayList<AudioQues>();
		List list=audioQuesDAO.findAll();
		if(list.size()>0){
			Iterator it=list.iterator();
			while(it.hasNext()){
				AudioQues current=(AudioQues) it.next();
				if((current.getType().equals(type))&&(current.getStatus().equals(status)))
					result.add(current);
				
			}
			
		}
		
		return result;
	}
	
	
}
